{% extends 'base.html' %}

{% block title %}
{{ super() }}
{% endblock title %}

{% block meta_tags_in_head %}
{{ super() }}
{% from '_includes/_defaults.html' import LANDING_PAGE_TITLE, FEATURED_IMAGE, SITE_DESCRIPTION with context %}
{% if LANDING_PAGE_TITLE %}
<meta property="og:title" content="{{ LANDING_PAGE_TITLE|e }}"/>
<meta name="twitter:title" content="{{ LANDING_PAGE_TITLE|e }}">
{% else %}
<meta property="og:title" content="{{ SITENAME|striptags|e }}"/>
<meta name="twitter:title" content="{{ SITENAME|striptags|e }}">
{% endif %}
<meta property="og:url" content="{{ SITEURL }}" />
<meta property="og:site_name" content="{{ SITENAME|striptags|e }}" />
<meta property="og:article:author" content="{{ AUTHOR }}" />
{% if FEATURED_IMAGE %}
<meta property="og:image" content="{{ FEATURED_IMAGE }}" />
<meta name="twitter:image" content="{{ FEATURED_IMAGE }}" >
{% endif %}
{% if SITE_DESCRIPTION %}
<meta property="og:description" content="{{ SITE_DESCRIPTION|e }}" />
<meta name="twitter:description" content="{{ SITE_DESCRIPTION|e }}">
{% endif %}
<meta name="keywords" content="{% for tag, _ in tags|sort %} {{ tag }}, {% endfor %}{% for category, _ in categories|sort %} {{ category }}, {% endfor %}" />
{% endblock meta_tags_in_head %}

{% block content %}
{% from '_includes/_defaults.html' import LANDING_PAGE_TITLE, PROJECTS, PROJECTS_TITLE with context %}

{% set landing_page = namespace(page=false) %}
{% for p in hidden_pages if p.slug == "landing-page-about-hidden" %}
{% set landing_page.page = p %}
{% endfor %}

<div class="row-fluid">
    {% if LANDING_PAGE_TITLE %}
    {% set css_class = 'span10 offset2' %}
    {% if PROJECTS and LANDING_PAGE_TITLE %}
    {% set css_class = 'span12' %}
    {% endif %}
    <header class="page-header {{ css_class }}">
    <h1><a href="{{ SITEURL }}">{{ LANDING_PAGE_TITLE }}</a></h1>
    </header>
    {% endif %}

    <div class="row-fluid">
        {% if LANDING_PAGE_TITLE and landing_page.page %}
        {% set css_class = 'span8 offset2' %}
        {% if PROJECTS and LANDING_PAGE_TITLE %}
        {% set css_class = 'span8' %}
        {% endif %}
        <div class="{{ css_class }}">
            <header>
                <h1 id="about-me">{{ landing_page.page.title }}</h1>
            </header>
            <div class="article-content">
                {{ landing_page.page.content }}
            </div>
        </div>
        {% endif %}

        {% if PROJECTS %}
        {% set css_class = 'span8 offset2' %}
        {% if PROJECTS and LANDING_PAGE_TITLE %}
        {% set css_class = 'span4' %}
        {% endif %}
        <div class="{{ css_class }}">
            <header>
            <h1 id="my-projects">{{ PROJECTS_TITLE }}</h1>
            </header>
            {% for project in PROJECTS %}
            <ul class="list-projects">
                <li>
                <a href="{{ project.url }}" title="{{ project.name }}">{{ project.name }}</a> <span class="proj-desc">{{ project.description }}</span>
                </li>
            </ul>
            {% endfor %}
        </div>
        {% endif %}
    </div>

    {% if articles %}
    {% set css_class = 'span8 offset2' %}
    {% if articles and PROJECTS and LANDING_PAGE_TITLE %}
    {% set css_class = 'span12' %}
    {% endif %}
    {% from '_includes/_defaults.html' import RECENT_ARTICLES_COUNT, ARCHIVES_URL, CATEGORIES_URL with context %}
    <div class="row-fluid">
        <div class="{{ css_class }}">
            <header>
            <h1 id="recent-posts">Recent Posts <a id="allposts" href="{{ SITEURL }}/{{ ARCHIVES_URL }}">all posts</a></h1>
            </header>
        <div class="recent-posts">
            {% for article in articles %}
            {% if loop.index0 < RECENT_ARTICLES_COUNT %}
            <div itemscope class="recent-posts-article">
                <a href="{{ SITEURL }}/{{ article.url }}">
                    {{ article.title }}
                    {% if article.subtitle %}
                    <small class="subtitle">
                        {{ article.subtitle }}
                    </small>
                    {% endif %}
                </a>
                <div class="recent-posts-posted">
                    posted in
                    <a href="{{ SITEURL }}/{{ CATEGORIES_URL }}#{{ article.category.slug }}-ref">{{ article.category }}</a>
                    <time itemprop="dateCreated" datetime="{{ article.date.isoformat() }}">{{ article.locale_date }}</time>
                </div>
                {% if RECENT_ARTICLE_SUMMARY %}
                    <p>{{ article.summary }}</p>
                {% endif %}
            </div>
            {% endif %}
            {% endfor %}
        </div>
        </div>
    </div>
    {% endif %}
</div>
{% endblock content %}
